﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Windows.Controls.Primitives;

namespace ProjectEdificio
{
    public partial class Usuarios : Window
    {
        private BDManagment bdm = null;
        private DataTable tabledata = null;
        private Authentication auti = null;

        public Usuarios()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bdm = BDManagment.getInstance();
            tabledata = bdm.getDataTableUsers();
            this.DataContext = tabledata.DefaultView;
            auti = Authentication.getInstance();
            //listViewUsers.ItemsSource = tabledata.DefaultView;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            NewUser n = new NewUser(true);
            n.ShowDialog();
        }
        
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxButton buttons = MessageBoxButton.YesNo;
            MessageBoxImage icon = MessageBoxImage.Question;
            if (auti.getUser().User != textUserSelected.Text)
            {
                if (MessageBox.Show("Desea eliminar al Usuario?", "Confirmación", buttons, icon) == MessageBoxResult.Yes)
                {
                    ClearUser c = new ClearUser(textUserSelected.Text);
                }
            }
            else
            {
                MessageBox.Show("No puede borrar este Usuario, ya que se encuentra logeado.");
            }
            
            
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            NewUser edit = new NewUser(false, textUserSelected.Text, textPassSelected.Text, textRangeSelected.Text, textEmailSelected.Text, textJobSelected.Text);
            edit.ShowDialog();
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

    }
}
